home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / LOADCHAR.H < prev    next >
Text File  |  1988-05-30  |  3KB  |  67 lines

  1. /* -*-C-*- loadchar.h */
  2. /*-->loadchar*/
  3. /**********************************************************************/
  4. /****************************** loadchar ******************************/
  5. /**********************************************************************/
  6.  
  7. void
  8. loadchar(c)
  9. BYTE c;        /* character number in current font */
  10.  
  11. /***********************************************************************
  12.     This simple version will do for now.  Even in a book DVI file, there
  13.     are unlikely to be more than about 25 fonts used and with an average
  14.     of 50 characters  each, this  is about  1250 character  definitions.
  15.     With typical character  sizes of 10  point type on  a 300  dots/inch
  16.     device, each would take a block of (10/72)*300 = 42 dots square,  or
  17.     about 84 words each,  for a total storage  requirement of 84*1250  =
  18.     105000 words.  This is  quite reasonable for  the DEC-20/60 and  VAX
  19.     Unix  implementations,  and  may  be  acceptable  on  large   memory
  20.     microprocessors like the MC68000 and NS16000.
  21.  
  22.     However, for future expansion, a  reference count of each  character
  23.     is  maintained,  and  the  total  storage  allocated  for  character
  24.     descriptions is recorded.  Then, when  malloc fails, or MAXCACHE  is
  25.     reached, the font  entries can  be scanned  to find  the least  used
  26.     characters whose  raster  storage  can  then  be  freed  and  malloc
  27.     retried.
  28. ***********************************************************************/
  29.  
  30. {
  31.     void (*charyy)();        /* subterfuge to get around PCC-20 bug */
  32.     register UNSIGN32 nwords;    /* how many 32-bit words we need */
  33.     register struct char_entry *tcharptr;
  34.  
  35.     if ((c < FIRSTPXLCHAR) || (LASTPXLCHAR < c)) /* check character range */
  36.     return;
  37.  
  38.     tcharptr = &(fontptr->ch[c]);
  39.  
  40.     if (!VISIBLE(tcharptr))    /* check for empty character rasters */
  41.     return;
  42.  
  43.     nwords = (UNSIGN32)(((tcharptr->wp+31) >> 5) * (tcharptr->hp));
  44.  
  45.     tcharptr->rasters = (UNSIGN32*)MALLOC((unsigned)(nwords*sizeof(UNSIGN32)));
  46.     if (tcharptr->rasters == (UNSIGN32*)NULL)
  47.     {
  48.     (void)sprintf(message,"loadchar():  Could not allocate %ld words of \
  49. raster space--used %ld words so far",
  50.         (long)nwords,(long)cache_size);
  51.     (void)fatal(message);
  52.     }
  53.     tcharptr->refcount = 0;        /* clear reference count */
  54.     cache_size += (INT32)nwords;    /* update cache size record */
  55.  
  56.     if (fontptr != pfontptr)
  57.     openfont(fontptr->n);
  58.  
  59.     if (fontfp == (FILE *)NULL)        /* do nothing if no font file */
  60.     return;
  61.  
  62.     /* Bug workaround: PCC-20 otherwise jumps to charxx instead of *charxx */
  63.     charyy = fontptr->charxx;
  64.     (void)(*charyy)(c,outrow);        /* load character from font file */
  65. }
  66.  
  67.